#pragma once

#include <pthread.h>
#include <signal.h>

#include <list>
using std::list;

#include "Thread.h"
#include "ThreadPool.h"
#include "Action.h"


class ActionDispatcher : public Thread
{
public:
    ActionDispatcher(void);
    ~ActionDispatcher(void);

    virtual void Run();

    static ActionDispatcher* GetInstance();

    void Assign(Action* pAction);
    void OnAction(Action* pAction);

private:
    //static ActionDispatcher m_instance;
    //static int m_nInitThreads;
    //static int m_nMaxThreads;

    static ActionDispatcher* m_instance;
    static int m_nInitThreads;
    static int m_nMaxThreads;

    list<Action *> m_listActions;
    Mutex m_mutex;
    Semaphore m_sem;
    ThreadPool* m_pThreadPool;
};


